

package com.hazelcast.query.impl.getters;

/**
 * NullMultiValue getter describes neutral behaviour for a {@link Getter}.
 * Always returns a MultiResult that indicates that the MultiValue object (Collection/Array) was null.
 */
public final class NullMultiValueGetter extends Getter {

    /**
     * Shared singleton instance of this class.
     */
    public static final NullMultiValueGetter NULL_MULTIVALUE_GETTER = new NullMultiValueGetter();

    private static final MultiResult<Object> NULL_MULTIVALUE_RESULT;

    static {
        MultiResult<Object> result = new MultiResult<>();
        result.addNullOrEmptyTarget();
        NULL_MULTIVALUE_RESULT = new ImmutableMultiResult<>(result);
    }

    private NullMultiValueGetter() {
        super(null);
    }

    @Override
    Object getValue(Object obj) throws Exception {
        return NULL_MULTIVALUE_RESULT;
    }

    @Override
    Class<?> getReturnType() {
        return null;
    }

    @Override
    boolean isCacheable() {
        return false;
    }
}
